<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>英雄新增</title>
    <!--  公共头部-->
    <div th:replace="admin/common :: head"></div>
    <link rel="stylesheet" href="../../../static/lib/editormd/css/editormd.min.css"  th:href="@{/lib/editormd/css/editormd.min.css}">
</head>
<body>

<!--导航栏-->
<div th:replace="admin/common :: menu(3)"></div>
<div class="m-padded-tb-hugex">
    <div class="ui attached pointing menu">
        <div class="ui container">
            <div class="right menu">
                <a href="#" class="teal active item">新增</a>
                <a href="#" th:href="@{/admin/hero}"  class="item">列表</a>
            </div>
        </div>
    </div>
</div>

<!--中间内容-->
<div class="">
    <div class="ui container">
        <form id="blog-form" th:action="@{/admin/hero/append}" method="post" class="ui form">
            <input type="hidden" name="publish">
            <input type="hidden" name="id">

            <div class="required field">
                <div class="ui left labeled input">
                    <div class="ui selection compact teal basic dropdown label">
                        <input type="hidden" value="原创" name="flag">
                        <i class="dropdown icon"></i>
                        <div class="text">原创</div>
                        <div class="menu">
                            <div class="item" data-value="原创">原创</div>
                            <div class="item" data-value="转载">转载</div>
                            <div class="item" data-value="翻译">翻译</div>
                        </div>
                    </div>
                    <input type="text" name="title" placeholder="标题">
                </div>
            </div>

            <div class="required field">
                <div class="" id="md-content" style="z-index: 1 !important;">
                    <textarea placeholder="英雄内容" name="content" style="display: none"></textarea>
                </div>
            </div>

            <div class="two fields">
                <div class="required field">
                    <div class="ui left labeled action input">
                        <label class="ui compact teal basic label">省份</label>
                        <div class="ui fluid selection dropdown">
                            <input type="hidden" name="provinceId" >
                            <i class="dropdown icon"></i>
                            <div class="default text">省份</div>
                            <div class="menu">
                                <div class="item" th:each="province:${provinces}" th:data-value="${province.provinceId}" th:text="${province.provinceName}" data-value="1">我的故事</div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="required field">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label">首图</label>
                        <input type="text" name="img" placeholder="首图引用地址">
                    </div>
                </div>
            </div>

            <div class="required field">
                <textarea name="description" placeholder="博客描述..." maxlength="200"></textarea>
            </div>

            <div class="inline fields">
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" id="shareOpen" name="shareOpen" class="hidden">
                        <label for="shareOpen">转载声明</label>
                    </div>
                </div>
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" id="moneyOpen" name="moneyOpen" class="hidden">
                        <label for="moneyOpen">赞赏</label>
                    </div>
                </div>
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" id="commentOpen" name="commentOpen" class="hidden">
                        <label for="commentOpen">评论</label>
                    </div>
                </div>
            </div>

            <div class="ui error message"></div>

            <div class="ui right aligned container">
                <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                <button type="button" id="save-btn" class="ui secondary button">保存</button>
                <button type="button" id="publish-btn" class="ui teal button">发布</button>
            </div>

        </form>
    </div>
</div>

<br>
<br>
<!--底部栏-->
<!--公共底部栏-->
<div th:replace="admin/common :: #footer"></div>

<!--公共js-->
<div th:replace="admin/common :: #js"></div>

<script src="../../../static/lib/editormd/editormd.min.js" th:src="@{/lib/editormd/editormd.min.js}"></script>


<script>
    //初始化Markdown编辑器
    var contentEditor;
    $(function () {
        contentEditor = editormd("md-content", {
            width: "100%",
            height: 640,
            syncScrolling: "single",
//        path    : "../static/lib/editormd/lib/"
            path: "/lib/editormd/lib/"
        });
    });
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    });

    $('.ui.dropdown').dropdown({
        on: 'hover'
    });

    $('#save-btn').click(function () {
        $('[name="publish"]').val(0);
        $('#blog-form').submit();
    });


    $('#publish-btn').click(function () {
        $('[name="publish"]').val(1);
        $('#blog-form').submit();
    });


    $('.ui.form').form({
        fields: {
            title: {
                title: 'title',
                rules: [{
                    type: 'empty',
                    prompt: '标题：请输入英雄标题'
                }]
            },
            content: {
                content: 'content',
                rules: [{
                    type: 'empty',
                    prompt: '标题：请输入英雄博客内容'
                }]
            },
            provinceId: {
                provinceId: 'provinceId',
                rules: [{
                    type: 'empty',
                    prompt: '标题：请输入英雄省份'
                }]
            },
            img: {
                img: 'img',
                rules: [{
                    type: 'empty',
                    prompt: '标题：请输入英雄博客首图'
                }]
            },
            description: {
                description: 'description',
                rules: [{
                    type: 'empty',
                    prompt: '标题：请输入英雄博客描述'
                }]
            }
        }
    });

</script>
</body>
</html>